Skip to content

TST: Test ArrowExtensionArray with decimal types #50964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Feb 22, 2023

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke commented Jan 24, 2023

closes #34166

@mroeschke mroeschke added the Arrow pyarrow functionality label Jan 24, 2023
@jbrockmendel
Copy link
Member

[XPASS(strict)] No pyarrow kernel for decimal128(4, 3)

@mroeschke mroeschke added this to the 2.0 milestone Jan 28, 2023
+ [Decimal("-2.0"), Decimal("-1.0")] * 44
+ [None]
+ [Decimal("0.5"), Decimal("33.123")]
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like if you pass Decimal("nan") to pyarrow it raises. is that going to be relevant for us?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we coerce to NA

In [6]: pd.Series([decimal.Decimal("nan")], dtype=pd.ArrowDtype(pa.decimal128(4, 1)))
Out[6]:
0    <NA>
dtype: decimal128(4, 1)[pyarrow]

Which I guess is fuzzy with the NA vs nan debate

request.node.add_marker(
pytest.mark.xfail(
raises=NotImplementedError,
reason=f"Parameterized types with tz={pa_dtype.tz} not supported.",
reason=f"Parameterized types {pa_dtype} not supported.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#50689 fixes this for timestamptz, after both this and that are merged we can see about fixing this for decimal.

@@ -4948,6 +4952,8 @@ def _get_engine_target(self) -> ArrayLike:
and not (
isinstance(self._values, ArrowExtensionArray)
and is_numeric_dtype(self.dtype)
# Exclude decimal
and self.dtype.kind != "O"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we be more specific than this? e.g. time32 would also go through here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_numeric_dtype(self.dtype) should block time32. I could import pyarrow and check pa.types.is_decimal if you prefer`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, this is fine

request.node.add_marker(
pytest.mark.xfail(
raises=NotImplementedError,
reason=f"pyarrow.type_for_alias cannot infer {pa_dtype}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this something we can patch in construct_from_string (OK for out of scope, just curious)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I believe so

Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending greenish

@mroeschke
Copy link
Member Author

Greenish. Merging.

@mroeschke mroeschke merged commit f5405b5 into pandas-dev:main Feb 22, 2023
@mroeschke mroeschke deleted the enh/arrow/decimal_testing branch February 22, 2023 20:31
@lumberbot-app
Copy link

lumberbot-app bot commented Feb 22, 2023

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 2.0.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 f5405b58e522f926e8fb6eef6c10ccb4ddf84a86
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #50964: TST: Test ArrowExtensionArray with decimal types'
  1. Push to a named branch:
git push YOURFORK 2.0.x:auto-backport-of-pr-50964-on-2.0.x
  1. Create a PR against branch 2.0.x, I would have named this PR:

"Backport PR #50964 on branch 2.0.x (TST: Test ArrowExtensionArray with decimal types)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

mroeschke added a commit to mroeschke/pandas that referenced this pull request Feb 22, 2023
* TST: Test ArrowExtensionArray with decimal types

* Version compat

* Add other xfails based on min version

* fix test

* fix typo

* another typo

* only for skipna

* Add comment

* Fix

* undo comments

* Bump version condition

* Skip masked indexing engine for decimal

* Some merge stuff

* Remove imaginary test

* Fix condition

* Fix another test

* Update condition

(cherry picked from commit f5405b5)
phofl pushed a commit that referenced this pull request Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Add high-performance DecimalArray type?
2 participants